"""
Toy example for infra-cascade-simulator-demo
-------------------------------------------
该示例使用虚拟网络（4电 + 4水），运行框架流程。
"""

import pandas as pd
from simulator_framework import InfraCascadeSimulator

# ====== 1. 伪造小网络数据 ======
adj = pd.DataFrame([
    [0,1,1,0,0,0,0,0],
    [1,0,1,1,0,0,0,0],
    [1,1,0,0,0,0,0,0],
    [0,1,0,0,1,0,0,0],
    [0,0,0,1,0,1,0,0],
    [0,0,0,0,1,0,1,1],
    [0,0,0,0,0,1,0,1],
    [0,0,0,0,0,1,1,0],
])

dep = pd.DataFrame([
    [0,0,0,0,0.5,0,0,0],
    [0,0,0,0,0.4,0,0,0],
    [0,0,0,0,0.6,0,0,0],
    [0,0,0,0,0.5,0,0,0],
    [0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0],
    [0,0,0,0,0,0,0,0],
])

nodes = pd.DataFrame({
    "id":   [f"N{i}" for i in range(8)],
    "system": ["power"] * 4 + ["water"] * 4,
    "load": [1,1.2,0.8,1.1, 0.9,1.3,1.0,1.1],
    "capacity": [2,2,2,2, 2,2,2,2],
})

# ====== 2. 调用仿真框架 ======
sim = InfraCascadeSimulator(adj, dep, nodes)

sim.apply_initial_failure(["N1"])  # 指定初始失效（DEMO）
sim.iterate(rounds=4)              # 运行仿真流程
sim.summary()                      # 输出摘要
